<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head runat="server">
		<meta charset="UTF-8">
	
		<title></title>

    <title></title>
    <style type="text/css" >
    .code
    {
            background:url(loginedResource/images/291743.jpg);
            text-shadow :1px 1px blue; 
            font-family:Arial;
            font-style:italic;
            opacity:0.5;
             color:red;
             font-size:25px;
             border:0;
             padding:2px 3px;
             letter-spacing:3px;
             font-weight:bolder;             
             float:left;            
             cursor:pointer;
             width:150px;
             height:20px;
             line-height:20px;
             text-align:center;
             vertical-align:middle;

    }
    a
    {
        text-decoration:none;
        font-size:12px;
        color:#288bc4;
        }
    a:hover
    {
       text-decoration:underline;
        }
    </style>
    <script language="javascript" type="text/javascript">

        var code;
        function createCode() {
        	
            code = "";
            var codeLength = 4; //验证码的长度
            var checkCode = document.getElementById("checkCode");
            var codeChars = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 
            'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); //所有候选组成验证码的字符，当然也可以用中文的
            for (var i = 0; i < codeLength; i++) 
            {
                var charNum = Math.floor(Math.random() * 52);
                code += codeChars[charNum];
            }
            if (checkCode) 
            {
                checkCode.className = "code";
                checkCode.innerHTML = code;
                checkCode.blur();
            }
        }
        function validateCode() 
        {
            var inputCode = document.getElementById("inputCode").value;
            if (inputCode.length <= 0) 
            {
                alert("请输入验证码！");
                return false;
            }
            else if (inputCode.toUpperCase() != code.toUpperCase()) 
            {
                alert("验证码输入有误！");
                createCode();
                return false;
            }
            else 
            {
                
                return true;
            }   
            
        }    
     </script>
	</head>
	<body onload="createCode()" background="loginedResource/images/291743.jpg">
		<form class="form-horizontal" action="UserLoginServlet" method="post"  id="form1" runat="server" onsubmit="validateCode()"> 
		
        <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label"><font color="yellow">姓名</font></label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="textName" name="textName" placeholder="Name">
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label"><font color="yellow">密码</font></label>
    <div class="col-sm-10">
      <input type="password" class="form-control" id="textPsw" name="textPsw" placeholder="Password">
    </div>
  </div>
  


    <div>
    <table border="0" cellspacing="3" cellpadding="3" >
        <tr>
            <td> <div class="code" id="checkCode" onclick="createCode()" ></div></td>
            <td><a  href="#" onclick="createCode()">看不清换一张</a></td>
        </tr>
        <tr><td><font color="yellow">请输入验证码</font></td></tr>
        <tr>
           <td><input  style="float:left;" type="text"   id="inputCode" /></td>
        </tr>
        
    </table>
    </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default" onclick="return validateCode()"><font color="bulue">登录</font></button>
    </div>
  </div>
  <div align="right"><font color="black">这是吕奎O.O嘿嘿</font></div>
    </form>

</body>
</html>